Skip to content

program-data-separation demo #42

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 1 commit into
base: main
Choose a base branch
from

Conversation

lucylq
Copy link
Contributor

@lucylq lucylq commented Jul 17, 2025

Add examples on how to generate PTE, PTD files, and how to run them in ExecuTorch via Module.

Note: I created a separate ET submodule --> we need the changes from 0.7 for this. However, I'm not sure we should be creating a new submodule for each project.

Issue: pytorch/executorch#12215

@meta-cla meta-cla bot added the CLA Signed This label is managed by the Meta Open Source bot. label Jul 17, 2025
@lucylq lucylq force-pushed the lfq.program-data-separation-example branch 6 times, most recently from 11059f6 to bd2e5c2 Compare July 17, 2025 21:43
@@ -2,3 +2,8 @@
path = mv2/cpp/executorch
url = https://github.com/pytorch/executorch.git
branch = release/0.6

[submodule "program-data-separation/cpp/executorch"]
Copy link
Contributor Author

@lucylq lucylq Jul 17, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Should we have ET as a submodule for each project, though?

Note: we don't have a release for 0.7, once we do we could potentially update and consolidate the two submodules?

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

yeah, eventually we could just have a common submodule directory

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

for now, don't worry about it

@lucylq lucylq marked this pull request as ready for review July 17, 2025 21:43
@lucylq lucylq requested a review from mergennachin July 17, 2025 21:44
@lucylq lucylq force-pushed the lfq.program-data-separation-example branch from bd2e5c2 to 588ae93 Compare July 17, 2025 21:49
Copy link
Contributor

@mergennachin mergennachin left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

See inline

# Program Data Separation Examples

This directory provides an example of the Program Data Separation APIs in ExecuTorch.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Give some motivation and high-level context of what and why

```
Or alternatively, [install conda on your machine](https://conda.io/projects/conda/en/latest/user-guide/install/index.html)
```bash
conda create -yn executorch-examples-mv2 python=3.10.0 && conda activate executorch-examples-mv2
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

use a different conda env name. executorch-examples-mv2 is a bit confusing

@@ -0,0 +1,45 @@

cmake_minimum_required(VERSION 3.18 FATAL_ERROR)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We might need to update to 3.29 now

@@ -0,0 +1,45 @@

cmake_minimum_required(VERSION 3.18 FATAL_ERROR)
project(executorch_mv2_demo CXX)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

use different project name

@@ -2,3 +2,8 @@
path = mv2/cpp/executorch
url = https://github.com/pytorch/executorch.git
branch = release/0.6

[submodule "program-data-separation/cpp/executorch"]
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

yeah, eventually we could just have a common submodule directory

[submodule "program-data-separation/cpp/executorch"]
path = program-data-separation/cpp/executorch
url = https://github.com/pytorch/executorch.git
branch = main
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

we have 'release/0.7' branch, so it should just work

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

only pip install executorch==0.7.0 will not work for the time being

const char *data_path = FLAGS_data_path.c_str();

// Load the model.
Module module(model_path, data_path);
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nice!!

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@shoumikhin , @kirklandsign

do we have support for swift and java bindings?

* LICENSE file in the root directory of this source tree.
*/

#include <executorch/extension/module/module.h>
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Comment on lines +103 to +109
with open(pte_file, "wb") as fp:
executorch_program.write_to_file(fp)
if executorch_program._tensor_data.get("_default_external_constant"):
executorch_program._tensor_data[model_name] = (
executorch_program._tensor_data.pop("_default_external_constant")
)
executorch_program.write_tensor_data_to_file(args.outdir)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

where are these AOT APIs document?

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@@ -2,3 +2,8 @@
path = mv2/cpp/executorch
url = https://github.com/pytorch/executorch.git
branch = release/0.6

[submodule "program-data-separation/cpp/executorch"]
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

for now, don't worry about it

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
CLA Signed This label is managed by the Meta Open Source bot.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants